package javaBase.nowcoder.HJ51_A_输出单向链表中倒数第k个结点;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while ((str = br.readLine()) != null) {
            int num = Integer.parseInt(str);
            String arr[] = br.readLine().split(" ");
            int index = Integer.parseInt(br.readLine());
            if (index < 0 || index > arr.length) {
                System.out.println(-1);
            } else {
                System.out.println(arr[num - index]);
            }
        }

    }
}
